home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 1408 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.8 KB  |  77 lines

  1. Path: news1.h1.usa.pipeline.com!usenet
  2. From: grantp@usa.pipeline.com(Pete)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: exception doesn't work with VC++ 2.2
  5. Date: 10 Jan 1996 20:59:38 GMT
  6. Organization: Pipeline USA
  7. Message-ID: <4d19bq$r8d@news1.usa.pipeline.com>
  8. NNTP-Posting-Host: pipe7.h1.usa.pipeline.com
  9. X-PipeUser: grantp
  10. X-PipeHub: usa.pipeline.com
  11. X-PipeGCOS: (Pete)
  12. X-Newsreader: Pipeline USA v3.3.0
  13.  
  14. On Jan 10, 1996 20:06:47 in article <exception doesn't work with VC++ 2.2>,
  15. 'john@mrinc.com (John Matzen)' wrote: 
  16.  
  17.  
  18. >I'm trying to update a record with the CRecordset::Update() function. 
  19. >When I do, the function returns FALSE and the record is not updated. 
  20.  
  21. The documentation says that FALSE (0) indicates that no columns 
  22. were changed.  An exception is only thrown in case the number of 
  23. records updated was something other than 1.  FALSE may very well be 
  24. the proper return value in your case. 
  25.  
  26. >I also can't seem to catch any exceptions from the function: 
  27. >In the following code block: 
  28. >try { 
  29. >    pDoc->setCustomer.Update(); 
  30. >} 
  31. >catch (...) { 
  32. >    AfxMessageBox("An exception occured updating record."); 
  33. >} 
  34. >the exception is not caught.  Also, I've tried numerous variations of 
  35. >this with try, and TRY, and catching specific exceptions and nothing 
  36. >works.  I have no idea why my record is not getting updated. 
  37. >Any ideas? 
  38. The exception mechanism works for me (See below).  I'd say that 
  39. CRecordset::Update method is not throwing an exception. 
  40.  
  41. #include <iostream.h> 
  42.  
  43. int test (int); 
  44.  
  45. int main ()  
  46.  { 
  47.    try 
  48.     { 
  49.       test (5); 
  50.     } 
  51.    catch (...) 
  52.     { 
  53.       cout << "Caught an exception.\n"; 
  54.       return 1; 
  55.     } 
  56.    cout << "No exceptions caught.\n"; 
  57.    return 0; 
  58.  } 
  59.  
  60.  
  61. int test (int n) 
  62.  { 
  63.    if (n > 2) 
  64.       throw n; 
  65.    return n * 2; 
  66.  } 
  67. /// returns "Caught an exception." on my machine. 
  68.  
  69. -- 
  70.  
  71. Pete
  72.